package com.thh.ftp.exception;


import com.thh.ftp.response.Result;
import com.thh.ftp.response.StatusCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class ExceptionCatch {
    private static final Logger LOGGER = LoggerFactory.getLogger(ExceptionCatch.class);




    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result exception(Exception e) {
        LOGGER.error("catch exception : {}\r\nexception: ", e.getMessage(), e);
        return  new Result(false, StatusCode.ERROR,e.getMessage());
    }

}
